﻿using System;
using System.Xml;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Application.Testing.XmlRepository.Helpers;

namespace AnimalsSerialization
{
    class Program
    {
        static void Main (string [] args)
        {
            List<MammalArmy> mammals = new List<MammalArmy>()
            {new Cheetah{mName = "Cheetah", mHealth = 120, mDamageInflicted = 10},
             new Tiger{mName = "Tiger", mHealth = 150, mDamageInflicted = 20},
             new Panther{mName = "Panther", mHealth = 100, mDamageInflicted = 10}};

            List<ReptileArmy> reptiles = new List<ReptileArmy> ()
            {new KingCobra{mName = "KingCobra", mHealth = 70, mDamageInflicted = 4},
             new Alligator{mName = "Alligator", mHealth = 110, mDamageInflicted = 10},
             new CaymanCrocodile{mName = "CaymanCrocodile", mHealth = 100, mDamageInflicted = 10}};

            
            DataContractSerializationHelper SerializationHelper = new DataContractSerializationHelper ();

            SerializationHelper.SaveModel ("D:\\MammalKind.xml", mammals);
            SerializationHelper.SaveModel ("D:\\ReptileKind.xml", reptiles);

            foreach (MammalArmy mammal in mammals)
            {
                mammal.IncreaseDamage ();
                mammal.GetOlder ();
            }
          
            foreach (ReptileArmy reptile in reptiles)
            {                
                reptile.GetOlder ();
                reptile.Regenerate ();
            }

            SerializationHelper.SaveModel ("D:\\MammalKind.xml", mammals);
            SerializationHelper.SaveModel ("D:\\ReptileKind.xml", reptiles);

            IEnumerable<MammalArmy> mammalsSave = SerializationHelper.LoadModelsCollection<MammalArmy> ("D:\\MammalKind.xml");
            IEnumerable<ReptileArmy> reptilesSave = SerializationHelper.LoadModelsCollection<ReptileArmy> ("D:\\ReptileKind.xml");
        }
    }
}
